<style>
.closepay {
    width: 1.5rem;
    height: 1.5rem;
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    border-radius: 1.5rem;
    text-align: center;
    line-height: 1.5rem;
    font-size: 1.3rem;
    color:{{main.syscolor||'#ff5555'}};
    z-index: 18;
}
</style>
<div id="newcore-pay-modal" class="modal fade" tabindex="-1" style="z-index:99999;display:none">
<div class="modal-dialog" style="width:100%;left:0%;bottom:0;">
<div class='modal-content' style="padding-bottom:0.6rem;border-bottom-left-radius:0;border-bottom-right-radius:0;">
		<div aria-hidden="true" data-dismiss="modal" class="closepay"><i class="icon jinyunicon icon-wrong" style="font-size: 1.3rem;"></i></div>
		<div class='fui-page-title bold c' style="padding-top:1.3rem;padding-bottom:0;font-size:1rem">支付订单</div>
		<div class='fui-page-title bold c'><span>￥</span>
		<span class="bigprice core-pay-fee" style="font-size:1.6rem">{{paydata.fee}}</span>
		<span ng-if="paydata.jianfee && paydata.jianfee>0" class="orange" style="font-size:0.5rem">减免:￥{{paydata.jianfee}}</span>
		</div>
		<div class="fui-page-title" style="margin-top:-0.3rem">
			<div ng-if="paydata.di_fee && paydata.di_fee>0" class="c subtitle">当前抵现:<span class="text-danger">￥{{paydata.di_fee}}</span></div>
			<div class="c subtitle">订单编号:<span class="core-pay-ordersn">{{paydata.tid}}</span></div>
		</div>
		<div class="weui_cells weui_cells_radio2" style="margin-top:10px;max-height:16rem;overflow-y:scroll">
			<label ng-if="paydata.iswechat==1 && paydata.fee>0 && paydata.isdiwechat!=1" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-weixin green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">微信支付</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='wechat'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='wechat'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.iscredit==1 && paydata.credit2.isdi!=1" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-icon green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">余额支付 <span>（可用 <span class='text-danger'>￥{{paydata.credit || '0.00'}}</span>）</span></div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='credit'">
						<input type="radio" name="type" class="weui_check" ng-checked="paydata.type=='credit'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<div ng-if="paydata.iscredit==1 && paydata.credit2.isdi==1" class="weui_cell">
					<div class='weui_cell_hd' style="width:1.6rem;">
						
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						余额（可用 <span class='text-danger'>￥{{paydata.credit || '0.00'}}</span>）
					</div>
					<div class="weui_cell_ft">
						-{{price(paydata.credit2.difee) || '0.00'}}
						<span style="width:2rem"><input class="weui_switch" type="checkbox" ng-checked="paydata.di_open=='credit2'" ng-click="toogle(paydata,'di_open',['credit2',0]);uppaydatadifee(paydata.credit2.difee);"></span>
					</div>
			</div>
			<div ng-repeat="item in paydata.creditdata" ng-class="{'weui_cell':1,'disabled':item.value<=0}" ng-if="item.isclose != 1">
					<div class='weui_cell_hd' style="width:1.6rem;">
						
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						{{item.title}}（可用 <span class='text-danger'>￥{{item.value || '0.00'}}</span>）
						
					</div>
					<div class="weui_cell_ft">
						<span style="margin-right:0.3rem">-{{price(item.difee)|| '0.00'}}</span>
						<input class="weui_switch" type="checkbox" ng-checked="paydata.di_open==item.field" ng-click="toogle(paydata,'di_open',[item.field,0]);uppaydatadifee(item.difee);">
					</div>
			</div>
			<label ng-if="paydata.isalipay_url!=1 && paydata.isalipay==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-qianbaopengyou green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">支付宝支付</div>
						<div class="subtitle">使用支付宝进行支付</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='alipay'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='alipay'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.isalipay_url==1 && paydata.fee>0" class="weui_cell weui_check_label">
				<div class='weui_cell_hd' style="width:auto;">
					<i class="icon icon-qianbaopengyou green" style="font-size:1.6rem"></i>
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<div class="title bold">支付宝支付</div>
					<div class="subtitle">使用支付宝进行支付</div>
				</div>
				<div class="weui_cell_ft" ng-click="paydata.type='alipay_url'">
					<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='alipay_url'">
					<span class="weui_icon_checked"></span>
				</div>
			</label>
			<label ng-if="paydata.isallinpay==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-qianbaopengyou green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">通联支付</div>
						<div class="subtitle">使用通联支付进行支付</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='allinpay'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='allinpay'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.isunion_wap==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-yiban green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">银联云闪付</div>
						<div class="subtitle">使用银联云闪付进行支付</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='union_wap'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='union_wap'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.isunion_online==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-yiban green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">银联H5支付</div>
						<div class="subtitle">使用银联H5支付进行支付</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='union_online'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='union_online'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.isfast_pay==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-yiban green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">快捷支付</div>
						<div class="subtitle">使用快捷支付进行支付</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='fast_pay'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='fast_pay'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.ishnapay==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-qianbaopengyou green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">新生支付</div>
						<div class="subtitle">使用新生支付进行支付</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='hnapay'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='hnapay'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.isdiypay==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-caifub green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">{{paydata.diypay_title||'核销支付'}}</div>
						<div class="subtitle">{{paydata.diypay_desc}}</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='diypay'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='diypay'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.isdiypay2==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-caifub green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">{{paydata.diypay2_title||'核销支付'}}</div>
						<div class="subtitle">{{paydata.diypay2_desc}}</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='diypay2'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='diypay2'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.isgo2pay==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-caifub green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">{{paydata.go2pay_title||'核销支付'}}</div>
						<div class="subtitle">{{paydata.go2pay_desc}}</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='go2pay'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='go2pay'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-if="paydata.ishdfk==1 && paydata.fee>0" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-tianmaohuodaofukuan green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">货到付款</div>
						<div class="subtitle">收到商品后进行付款</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='hdfk'">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='hdfk'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
			<label ng-repeat="a in paydata.api" ng-if="a.open==1" class="weui_cell weui_check_label">
					<div class='weui_cell_hd' style="width:auto;">
						<i class="icon icon-zhuanzhang green" style="font-size:1.6rem"></i>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<div class="title bold">{{a.title}}</div>
						<div class="subtitle">{{a.desc}}</div>
					</div>
					<div class="weui_cell_ft" ng-click="paydata.type='apipay';paydata.api_name=a.name">
						<input type="radio" name="type" id="type" class="weui_check" ng-checked="paydata.type=='apipay'">
						<span class="weui_icon_checked"></span>
					</div>
			</label>
        </div>
		<a href="javascript:;" ng-click="new_gotopay();" class="weui_btn weui_btn_primary" style="margin:0.5rem 1rem;border-radius:1rem">确认支付</a>
</div>
</div>
</div>
<script>
scope.new_gotopay=function(){
	if(!scope.paydata.type){
		scope.message('请选择支付方式！');
		return false;
	}
	var pay_type=scope.paydata.type;
	scope.tool.pay(scope.paydata.id,function(res){
			//console.log('new_gotopay');console.log(res);
			var complete_url= scope.paydata.complete_url?scope.paydata.complete_url:'';
			var fail_url= scope.paydata.fail_url?scope.paydata.fail_url:complete_url;
			//console.log('new_gotopay');console.log(complete_url);
			if(res.type=='success'){
					var msg=scope.paydata.type=='hdfk'?'下单成功，请保持电话畅通！':'支付成功！';
					scope.message(msg,'success',complete_url);
			}else{
					scope.message('支付失败！','success',fail_url);
			}
	},pay_type);
	$('#newcore-pay-modal').modal('hide');
}
scope.uppaydatadifee=function(difee){
	if(scope.paydata.di_open!=0){
		//console.log('difee');console.log(difee);
		scope.paydata.di_fee=difee
		if(scope.paydata.fee<=difee && scope.paydata.type!='credit'){
			scope.paydata.type='credit';
		}
		if(scope.paydata.fee>difee){
			scope.paydata.isdiwechat=0;
		}else{
			scope.paydata.isdiwechat=1;
		}
	}else{
		scope.paydata.di_fee=0
		scope.paydata.isdiwechat=0;
	}
	scope.$evalAsync();
}
</script>